package com.mao.shiro_jsp.utils;


import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

/**
 * @author 小毛同学
 * @version 1.0
 * @data 2021/12/30 15:01
 */

@Component
public class ApplicationContextUtils implements ApplicationContextAware {

    private static ApplicationContext context;
    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        context = applicationContext;
    }

    // 通过Bean的名字获取工厂中的自定义Bean对象
    public static Object getBean(String BeanName){
        return context.getBean(BeanName);
    }
}
